<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <meta name="description" content="@section('description')@show">
    <meta name="keyword" content="@section('keyword'){{\App\Models\Site::first()->keywords ?? ''}}@show">
    <title>@section('title'){{\App\Models\Site::first()->name ?? ''}}@show</title>
    <!-- Fonts -->
    <link rel="dns-prefetch" href="https://fonts.gstatic.com">
    {{--<link href="https://fonts.googleapis.com/css?family=Raleway:300,400,600" rel="stylesheet" type="text/css">--}}

    <!-- Styles -->
    <link href="{{ asset('css/app.css') }}" rel="stylesheet">
    <link href="{{asset('plugins/Font-Awesome-3.2.1/css/font-awesome.min.css')}}" rel="stylesheet">
    @yield('styles')
    <script>
        var _hmt = _hmt || [];
        (function() {
            var hm = document.createElement("script");
            hm.src = "https://hm.baidu.com/hm.js?e3b66435e5e4660f7f54ff995ed938cc";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
        })();
    </script>

</head>
<body>
    <div id="app">
        <nav class="navbar navbar-expand-sm bg-white navbar-light card">
            <div class="container">
                {{--<a class="nav-link text-primary" href="{{route('communities')}}">--}}
                    {{--@if(isset($global_community))--}}
                        {{--【{{$global_community->province->name}}<span> • </span>{{$global_community->city->name}}-{{$global_community->name}} <span class="small text-muted">切换</span>】--}}
                    {{--@else--}}
                        {{--【选择社区】--}}
                    {{--@endif--}}
                {{--</a>--}}
                <a class="nav-link text-primary" href="{{route('cities')}}">
                    @if(isset($global_city))
                        【{{$global_city->name}}<span> • </span> <span class="small text-muted">切换</span>】
                    @else
                        【切换城市】
                    @endif
                </a>
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>

                <div class="collapse navbar-collapse" id="navbarSupportedContent">
                    <!-- Left Side Of Navbar -->
                    <ul class="navbar-nav">
                        <li class="nav-item {{Request::is('topics')?'active':''}}">
                            {{--<a class="nav-link" href="{{route('topics')}}">全部动态</a>--}}
                            <a class="nav-link" href="{{\gl\url(route('topics'))}}">全部动态</a>
                        </li>
                        @if (isset($categories) && !$categories->isEmpty())
                            @foreach($categories as $category)
                                <li class="nav-item {{Request::is("topics/{$category->id}","topics/{$category->id}/*")?'active':''}}">
                                    {{--<a class="nav-link" href="{{route('topics',[$category->id])}}">{{$category->name ?? ''}}</a>--}}
                                    <a class="nav-link" href="{{\gl\url(route('topics',[$category->id]))}}">{{$category->name ?? ''}}</a>
                                </li>
                            @endforeach
                        @endif
                    </ul>

                    <!-- Right Side Of Navbar -->
                    <ul class="navbar-nav ml-auto">
                        <!-- Authentication Links -->
                        @guest
                            <li><a class="nav-link" href="{{ route('login') }}">{{ __('登录') }}</a></li>
                            <li><a class="nav-link" href="{{ route('register') }}">{{ __('注册') }}</a></li>
                        @else
                            <li style="margin-top:6px;margin-right: 10px;">
                                <a href="{{route('notification')}}" class="notifications-badge">
                                    <span title="消息提醒" class="badge {{$notifications_count > 0?'badge-hint':'badge-fade'}} ">{{$notifications_count ?? 0}}</span>
                                </a>
                            </li>
                            <li class="nav-item dropdown">

                                <a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>

                                    <span class="user-avatar pull-left" style="margin-right: 8px; margin-top: -5px;"><img src="{{Auth::user()->avatar}}" width="30px" height="30px" class="img-fluid rounded-circle"></span>
                                    {{ Auth::user()->name }} <span class="caret"></span>
                                </a>
                                <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                                    @if(Auth::user()->canLoginAdmin())
                                        <a class="dropdown-item" href="{{route('admin.topics')}}">
                                            <i class=" icon-time"></i>
                                            {{ __('管理后台') }}
                                        </a>
                                    @endif
                                    <a class="dropdown-item" href="{{ route('user',[Auth::user()->id]) }}">
                                        <i class="icon-user"></i>
                                        个人中心
                                    </a>
                                    <a class="dropdown-item" href="{{ route('user.edit') }}">
                                        <i class="icon-edit"></i>
                                        编辑资料
                                    </a>
                                    <a class="dropdown-item" href="{{ route('logout') }}"
                                       onclick="event.preventDefault();document.getElementById('logout-form').submit();">
                                        <i class="icon-signout"></i>
                                        {{ __('退出登录') }}
                                    </a>



                                    <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
                                        @csrf
                                    </form>
                                </div>
                            </li>
                        @endguest
                    </ul>
                </div>
            </div>
        </nav>

        <main class="py-4">
            @yield('content')
        </main>
        <footer class="footer navbar bg-white card">
            <div class="container">
                {{--<div class="row">--}}
                    {{--<div class="col-sm-12">--}}
                        {{--<h4>统计信息</h4>--}}
                        {{--<ul class="list-unstyled">--}}
                            {{--<li>话题数: {{\App\Models\Topics::count()}} </li>--}}
                            {{--<li>评论数: {{\App\Models\Replies::count()}} </li>--}}
                        {{--</ul>--}}
                    {{--</div>--}}

                {{--</div>--}}
                <p class="text-center links" style="width: 100%;"><a target="_blank" href="http://www.miitbeian.gov.cn">鄂ICP备18014061号</a> | 联系邮箱：<a href="mailto:postmaster@xiaoquu.com?subiect=来自小区">postmaster@xiaoquu.com</a></p>
                <p></p>
            </div>
        </footer>
    </div>


    <a id="scrollUp" href="#top" style="position: fixed; z-index: 2147483647; display: none">Scroll to top</a>
    <!-- Scripts -->
    <script src="{{ asset('js/app.js') }}"></script>
    @yield('scripts')
    {{--@if (config('app.env') != 'production')--}}
        {{--@include('sudosu::user-selector')--}}
    {{--@endif--}}

    <script>
        window.onscroll = function() {
            var documentTop = Func.getDocumentTop();
            var windowHeight = Func.getWindowHeight();
            if (documentTop > windowHeight) {
                $('#scrollUp').css('display','');
            } else {
                $('#scrollUp').css('display','none');
            }
        }
    </script>
</body>
</html>
